<?php

	// PHP google_sitemap Generator

	require_once( "google_sitemap.class.php" );
	
	
	$link = mysql_connect('mysql1.wannafind.dk', 'myaudiomet', '00juu90v');
	if (!$link) {
		die('Could not connect: ' . mysql_error());
	}
	mysql_select_db('myaudiometer_com_db'); 




	// these day may be retrieved from DB
	$cats[] = array(
						"loc" => "myaudiometer.com/",
						"changefreq" => "weekly",
					);
    
	//page
	$getpage_sql = "select page_title_slug, page_date from aa_pages where page_status = 1";
	$getpage_rs = mysql_query($getpage_sql);
	while($getpage_row = mysql_fetch_array($getpage_rs))
	{
		$cats[] = array(
						"loc" => "myaudiometer.com/p/".$getpage_row['page_title_slug']."/",
						"changefreq" => "weekly",
					);
	}
	
	//catergory
	$cats[] = array(
						"loc" => "myaudiometer.com/category/news/",
						"changefreq" => "weekly",
					);
					
	$cats[] = array(
						"loc" => "http://myaudiometer.com/category/tips-tricks/",
						"changefreq" => "weekly",
					);				
					
	//postentry
    $getpost_sql = "select post_title_slug, post_date from aa_posts where post_status = 1";
	$getpost_rs = mysql_query( $getpost_sql);
	while($getpost_row = mysql_fetch_array($getpost_rs))
	{
		$cats[] = array(
						"loc" => "myaudiometer.com/entry/".$getpost_row['post_title_slug']."/",
						"changefreq" => "weekly",
					);
	}
	  
	
	
	mysql_close($link);
		
		
	$site_map_container =& new google_sitemap();

	for ( $i=0; $i < count( $cats ); $i++ )
	{
		$value = $cats[ $i ];

		$site_map_item =& new google_sitemap_item( $value[ 'loc' ], "", $value[ 'changefreq' ], "0.8" );

		$site_map_container->add_item( $site_map_item );
	}

	header( "Content-type: application/xml; charset=\"".$site_map_container->charset . "\"", true );
	header( 'Pragma: no-cache' );

	print $site_map_container->build();

?> 